From b5bdea9ad60fb7d0be72cbfb01a2e31625e7ae88 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Tue, 20 Dec 2005 12:50:09 +0100 Subject: [PATCH] This patch fix several issue to support >2G 64bit vmx guest in IA-32e platform, it includes: 1) One fix on xc_vmx_build.c 2) Change ram_size/phys_ram_size in qemu from int to uint64_t 3) One fix on pcnet unsigned short to unsigned long conversion. Signed-off-by: Yunhong Jiang Signed-off-by: Xin Li --- tools/ioemu/cpu-all.h | 2 +- tools/ioemu/exec.c | 2 +- tools/ioemu/hw/pc.c | 4 ++-- tools/ioemu/hw/pcnet.h | 4 ++-- tools/ioemu/vl.c | 4 ++-- tools/ioemu/vl.h | 4 ++-- tools/libxc/xc_vmx_build.c | 15 ++++++++------- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tools/ioemu/cpu-all.h b/tools/ioemu/cpu-all.h index 75544bee28..7d4a01b93f 100644 --- a/tools/ioemu/cpu-all.h +++ b/tools/ioemu/cpu-all.h @@ -668,7 +668,7 @@ static __inline__ void atomic_clear_bit(long nr, volatile void *addr) #endif /* memory API */ -extern int phys_ram_size; +extern uint64_t phys_ram_size; extern int phys_ram_fd; extern uint8_t *phys_ram_base; extern uint8_t *phys_ram_dirty; diff --git a/tools/ioemu/exec.c b/tools/ioemu/exec.c index 8bd69764e6..b6d1021d0e 100644 --- a/tools/ioemu/exec.c +++ b/tools/ioemu/exec.c @@ -61,7 +61,7 @@ spinlock_t tb_lock = SPIN_LOCK_UNLOCKED; uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE]; uint8_t *code_gen_ptr; -int phys_ram_size; +uint64_t phys_ram_size; int phys_ram_fd; uint8_t *phys_ram_base; uint8_t *phys_ram_dirty; diff --git a/tools/ioemu/hw/pc.c b/tools/ioemu/hw/pc.c index 5de7555045..714d6cb0b3 100644 --- a/tools/ioemu/hw/pc.c +++ b/tools/ioemu/hw/pc.c @@ -119,7 +119,7 @@ static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd) } /* hd_table must contain 4 block drivers */ -static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table) +static void cmos_init(uint64_t ram_size, int boot_device, BlockDriverState **hd_table) { RTCState *s = rtc_state; int val; @@ -375,7 +375,7 @@ static int serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 }; #define NOBIOS 1 /* PC hardware initialisation */ -void pc_init(int ram_size, int vga_ram_size, int boot_device, +void pc_init(uint64_t ram_size, int vga_ram_size, int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename) diff --git a/tools/ioemu/hw/pcnet.h b/tools/ioemu/hw/pcnet.h index a446802428..a1d3b73727 100644 --- a/tools/ioemu/hw/pcnet.h +++ b/tools/ioemu/hw/pcnet.h @@ -92,7 +92,7 @@ #define CSR_NRBA(S) ((S)->csr[22] | ((S)->csr[23] << 16)) #define CSR_BADR(S) ((S)->csr[24] | ((S)->csr[25] << 16)) #define CSR_NRDA(S) ((S)->csr[26] | ((S)->csr[27] << 16)) -#define CSR_CRDA(S) ((S)->csr[28] | ((S)->csr[29] << 16)) +#define CSR_CRDA(S) ((S)->csr[28] | (((uint32_t)((S)->csr[29])) << 16)) #define CSR_BADX(S) ((S)->csr[30] | ((S)->csr[31] << 16)) #define CSR_NXDA(S) ((S)->csr[32] | ((S)->csr[33] << 16)) #define CSR_CXDA(S) ((S)->csr[34] | ((S)->csr[35] << 16)) @@ -102,7 +102,7 @@ #define CSR_NXBA(S) ((S)->csr[64] | ((S)->csr[65] << 16)) #define PHYSADDR(S,A) \ - (BCR_SSIZE32(S) ? (A) : (A) | ((0xff00 & (uint32_t)(s)->csr[2])<<16)) + (BCR_SSIZE32(S) ? (A) : (A) | ((0xff00 & (uint32_t)(S)->csr[2])<<16)) struct pcnet_initblk16 { uint16_t mode; diff --git a/tools/ioemu/vl.c b/tools/ioemu/vl.c index 19b4333305..6d1073f3dc 100644 --- a/tools/ioemu/vl.c +++ b/tools/ioemu/vl.c @@ -119,7 +119,7 @@ const char* vncconnect; /* do a reverse connect to this host*/ const char* keyboard_layout = 0; int64_t ticks_per_sec; int boot_device = 'c'; -int ram_size; +uint64_t ram_size; int domid = -1; static char network_script[1024]; int pit_min_timer_count = 0; @@ -2906,7 +2906,7 @@ int main(int argc, char **argv) help(); break; case QEMU_OPTION_m: - ram_size = atoi(optarg) * 1024 * 1024; + ram_size = atol(optarg) * 1024 * 1024; if (ram_size <= 0) help(); break; diff --git a/tools/ioemu/vl.h b/tools/ioemu/vl.h index b05c22f964..3eb847972f 100644 --- a/tools/ioemu/vl.h +++ b/tools/ioemu/vl.h @@ -116,7 +116,7 @@ extern int audio_enabled; extern int sb16_enabled; extern int adlib_enabled; extern int gus_enabled; -extern int ram_size; +extern uint64_t ram_size; extern int bios_size; extern int rtc_utc; extern int cirrus_vga_enabled; @@ -649,7 +649,7 @@ int pit_get_gate(PITState *pit, int channel); int pit_get_out(PITState *pit, int channel, int64_t current_time); /* pc.c */ -void pc_init(int ram_size, int vga_ram_size, int boot_device, +void pc_init(uint64_t ram_size, int vga_ram_size, int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename); diff --git a/tools/libxc/xc_vmx_build.c b/tools/libxc/xc_vmx_build.c index 2146c83fc8..9d0fbc18d5 100644 --- a/tools/libxc/xc_vmx_build.c +++ b/tools/libxc/xc_vmx_build.c @@ -288,11 +288,11 @@ static int setup_guest(int xc_handle, l2_pgentry_t *vl2tab=NULL, *vl2e=NULL; unsigned long *page_array = NULL; #ifdef __x86_64__ - l3_pgentry_t *vl3tab=NULL, *vl3e=NULL; + l3_pgentry_t *vl3tab=NULL; unsigned long l3tab; #endif - unsigned long l2tab; - unsigned long l1tab; + unsigned long l2tab = 0; + unsigned long l1tab = 0; unsigned long count, i; shared_info_t *shared_info; void *e820_page; @@ -323,7 +323,7 @@ static int setup_guest(int xc_handle, } /* memsize is in megabytes */ - v_end = memsize << 20; + v_end = (unsigned long)memsize << 20; #ifdef __i386__ nr_pt_pages = 1 + ((memsize + 3) >> 2); @@ -435,15 +435,16 @@ static int setup_guest(int xc_handle, goto error_out; memset(vl2tab, 0, PAGE_SIZE); munmap(vl2tab, PAGE_SIZE); + vl2tab = NULL; vl3tab[i] = l2tab | L3_PROT; } - vl3e = &vl3tab[l3_table_offset(0)]; for ( count = 0; count < (v_end >> PAGE_SHIFT); count++ ) { - if (!(count & (1 << (L3_PAGETABLE_SHIFT - L1_PAGETABLE_SHIFT)))){ + if ( !(count & ((1 << (L3_PAGETABLE_SHIFT - L1_PAGETABLE_SHIFT)) - 1)) ) + { l2tab = vl3tab[count >> (L3_PAGETABLE_SHIFT - L1_PAGETABLE_SHIFT)] - & PAGE_MASK; + & PAGE_MASK; if (vl2tab != NULL) munmap(vl2tab, PAGE_SIZE); -- 2.30.2